/*
 * @Copyright: 2017 www.yyfax.com Inc. All rights reserved.
 */
package com.yyfax.pay.order.data.service;

import com.yyfax.framework.exception.YYException;
import com.yyfax.pay.common.enums.OrderStateEnum;
import com.yyfax.pay.order.model.po.PayoutOrderPO;
import com.yyfax.pay.order.model.vo.PayBusiIdVO;
import com.yyfax.pay.order.model.vo.PayoutOrderVO;

import java.util.List;

/**
 * 代付订单服务接口
 *
 * @author buyi
 * @date 2017-04-12 11:09:15
 * @since 1.0.0
 */
public interface PayoutOrderService {

	/**
	 * 解析支付订单业务主键规则
	 * 
	 * @author buyi
	 * @date 2017-04-15 14:18:19
	 * @since v1.0.0
	 * @param payOrderId
	 * @return
	 * @throws YYException
	 */
	public PayBusiIdVO resolverPayoutOrderId(String payoutOrderId) throws Exception;

	/**
	 * 根据代付业务订单查询
	 * 
	 * @author buyi
	 * @date 2018-05-25 10:20:28
	 * @since v1.0.0
	 * @param busiId 支付业务订单号payout_order_id
	 * @return
	 */
	public PayoutOrderPO queryByPayoutOrderId(String payoutOrderId);

	/**
	 * 根据主键查询实体
	 *
	 * @author buyi
	 * @date 2017年4月3日上午1:28:16
	 * @since 1.0.0
	 * @param id 主鍵
	 * @param merchantCode 商户编号(分表预留参数)
	 * @return
	 * @throws Exception
	 */
	public PayoutOrderPO queryByIdAndMerchantCode(int id, String merchantCode) throws Exception;

	/**
	 * 根据商户订单号查询
	 * 
	 * @author buyi
	 * @date 2017-04-18 10:18:55
	 * @since v1.0.0
	 * @param orderId
	 * @param merchantCode
	 * @return
	 * @throws Exception
	 */
	public PayoutOrderPO queryByOrderIdAndMerchantCode(String orderId, String merchantCode) throws Exception;

	/**
	 * 查询代付订单快照信息
	 * 
	 * @author buyi
	 * @date 2017-04-18 14:05:24
	 * @since v1.0.0
	 * @param orderId
	 * @param merchantCode
	 * @return
	 * @throws Exception
	 */
	public PayoutOrderVO queryPayoutOrderVOByOrderId(String orderId, String merchantCode) throws Exception;

	/**
	 * 根据批量代付订单号查询代付订单快照列表
	 * 
	 * @author buyi
	 * @date 2017-04-20 11:25:10
	 * @since v1.0.0
	 * @param merchantCode
	 * @param payoutBatchOrderId
	 * @return
	 */
	public List<PayoutOrderVO> queryPayoutOrderVoList(String merchantCode, String payoutBatchOrderId);

	/**
	 * 保存实体对象，并返回业务主键
	 *
	 * @author buyi
	 * @date 2017年4月3日上午1:28:22
	 * @since 1.0.0
	 * @param po 实体对象
	 * @return 返回主鍵，如果返回-1,0表示失败
	 * @throws Exception
	 */
	public String saveAndReturnBusiKey(PayoutOrderPO po) throws Exception;

	/**
	 * 更新代付订单信息
	 * 
	 * @author buyi
	 * @date 2017-04-18 11:07:33
	 * @since v1.0.0
	 * @param payoutOrderPO
	 * @throws Exception
	 */
	public void modify(PayoutOrderPO payoutOrderPO) throws Exception;

	/**
	 * 保存代付订单信息<br>
	 * 前置要封装好PayoutOrderPO所有信息，包括业务主键
	 * 
	 * @author buyi
	 * @date 2018-05-11 23:27:04
	 * @since v2.1.5
	 * @param po
	 * @return
	 */
	public int save(PayoutOrderPO po);

	/**
	 * @author buyi
	 * @date 2018-05-12 03:11:14
	 * @since v2.1.5
	 * @param origState
	 * @param destState
	 * @param rspCode
	 * @param rspMsg
	 * @return
	 */
	public int updateState(String payoutOrderId, OrderStateEnum origState, OrderStateEnum destState, int rspCode, String rspMsg);

	/**
	 * 更新订单状态
	 *
	 * @author wujiande
	 * @date 2018/5/11 23:46
	 * @since v2.1.5
	 * @param payoutOrderId
	 * @param state
	 * @param rspCode
	 * @param rspMsg
	 * @return 更新成功的数量
	 */
	int updateStateByPayoutOrderId(String payoutOrderId, String state, Integer rspCode, String rspMsg);

	/**
	 * 更新退票通知
	 * 
	 * @author buyi
	 * @date 2018-05-25 10:36:59
	 * @since v2.1.5
	 *
	 * @param payoutOrderId
	 * @param fail
	 * @param code
	 * @param desc
	 * @param value
	 * @param value2
	 * @return
	 */
	public int updateRefundState(String payoutOrderId, OrderStateEnum fail, int code, String desc, String value, String value2);
}
